import request from '@/utils/http.ts';
//轮播图
export const GetBannerInfo = () => {
  return request({
    url: 'banner',
    method: 'get'
  })
}
//专属歌单
export const GetPersonalizedInfo = () => {
  return request({
    url: '/personalized?limit=24',
    method: 'get'
  })
}
//推荐MV
export const GetMvInfo = () => {
  return request({
    url: '/mv/first?limit=4',
    method: 'get'
  })
}
//最新音乐
export const GetNewMusicInfo = () => {
  return request({
    url: '/personalized/newsong?limit=12',
    method: 'get'
  })
}
/* discover结束--------------------------------------------------- */

//歌单排行榜
export const GetToplistInfo = () => {
  return request({
    url: `toplist/detail?t=${new Date().getTime()}`,
    method: 'get'
  })
}
//歌单中歌曲
export const GetPlayListSong = (id: number, limit?: number, offset?: number) => {
  return request({
    url: `playlist/track/all?id=${id}&limit=${limit}&offset=${offset}`,
    method: 'get'
  })
}
/* list结束--------------------------------------------------------- */

//歌单详情
export const GetPlayListInfo = (id: number) => {
  return request({
    url: `playlist/detail?id=${id}`,
    method: 'get'
  })
}
/* playlist结束----------------------------------------------------- */

export const GetcateGorPlayList = (cat: string, limit: number, offset: number, t: number) => {
  return request({
    url: `top/playlist?cat=${cat}&limit=${limit}&offset=${offset}&t=${t}`,
    method: 'get'
  })
}
//分类标签
export const GetCateGorTags = () => {
  return request({
    url: `playlist/highquality/tags?t=${new Date().getTime()}`,
    method: 'get'
  })
}
/* 分类歌单结束----------------------------------------------------- */

//歌曲url
export const GetSongUrl = (id: number) => {
  return request({
    url: `song/url?id=${id}&t=${new Date().getTime()}`,
    method: 'get'
  })
}

//歌曲信息
export const GetSongInfo = (ids: number) => {
  return request({
    url: `song/detail?ids=${ids}&t=${new Date().getTime()}`,
    method: 'get'
  })
}

//歌曲歌词
export const GetSongLyric = (id: number) => {
  return request({
    url: `lyric?id=${id}&t=${new Date().getTime()}`,
    method: 'get'
  })
}
/* 歌词部分结束---------------------------------------------------- */

//搜索
export const GetSearchInfo = (keywords: string, type?: number, limit?: number, offset?: number) => {
  return request({
    url: `cloudsearch?keywords=${keywords}&type=${type}&limit=${limit}&offset=${offset}&t=${new Date().getTime()}`,
    method: 'get'
  })
}
/* 搜索结束-------------------------------------------------------- */

//歌手分类
export const GetSingerImg = (type: number, area: number, initial: string, page: number, limit: number, offset: number) => {
  return request({
    url: `artist/list?type=${type}&area=${area}&initial=${initial}&page=${page}&limit=${limit}&offset=${offset}`,
    method: 'get'
  });
};
//歌手信息
export const useArtistDetail = (id: number) => {
  return request({
    url: `artist/detail?id=${id}`,
    method: 'get'
  });
};
//歌手的歌曲
export const useArtistSongs = (id: number, order: string , limit: number , offset: number) => {
  return request({
    url: `artist/songs?id=${id}&order=${order}&limit=${limit}&offset=${offset}`,
    method: 'get'
  })
}

/* 登录接口开始------------------------------ */
//key生成接口
export const GetLoginKey = () => {
  return request({
    url: `/login/qr/key?timestamp=${new Date().getTime()}`,
    method: 'get'
  });
};
//生成二维码接口
export const GetCodeImg = (key: string, qrimg: boolean) => {
  return request({
    url: `/login/qr/create?key=${key}&timestamp=${new Date().getTime()}&qrimg=${qrimg}`,
    method: 'get'
  });
};
//检查扫描状态
export const checkCodeStaus = (key: string) => {
  return request({
    url: `/login/qr/check?key=${key}&timestamp=${new Date().getTime()}`,
    method: 'get'
  });
};
//邮箱登录
export const userLogin = (email: string, password: string) => {
  return request({
    url: `login?email=${email}&password=${password}`,
    method: 'get'
  });
};